home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / perl5 / Gnome2 / Canvas.pod < prev    next >
Encoding:
Text File  |  2008-06-14  |  12.2 KB  |  622 lines

  1. =head1 NAME
  2.  
  3. Gnome2::Canvas -  A structured graphics canvas
  4.  
  5. =for position SYNOPSIS
  6.  
  7. =head1 SYNOPSIS
  8.  
  9.   use strict;
  10.   use Gtk2 -init;
  11.   use Gnome2::Canvas;
  12.   my $window = Gtk2::Window->new;
  13.   my $scroller = Gtk2::ScrolledWindow->new;
  14.   my $canvas = Gnome2::Canvas->new;
  15.   $scroller->add ($canvas);
  16.   $window->add ($scroller);
  17.   $window->set_default_size (150, 150);
  18.   $canvas->set_scroll_region (0, 0, 200, 200);
  19.   $window->show_all;
  20.  
  21.   my $root = $canvas->root;
  22.   Gnome2::Canvas::Item->new ($root, 'Gnome2::Canvas::Text',
  23.                              x => 20,
  24.                              y => 15,
  25.                              fill_color => 'black',
  26.                              font => 'Sans 14',
  27.                              anchor => 'GTK_ANCHOR_NW',
  28.                              text => 'Hello, World!');
  29.   my $box = Gnome2::Canvas::Item->new ($root, 'Gnome2::Canvas::Rect',
  30.                                        x1 => 10, y1 => 5,
  31.                                        x2 => 150, y2 => 135,
  32.                                        fill_color => 'red',
  33.                                        outline_color => 'black');
  34.   $box->lower_to_bottom;
  35.   $box->signal_connect (event => sub {
  36.           my ($item, $event) = @_;
  37.           warn "event ".$event->type."\n";
  38.   });
  39.  
  40.   Gtk2->main;
  41.  
  42. =cut
  43.  
  44.  
  45.  
  46. =for position DESCRIPTION
  47.  
  48. =head1 DESCRIPTION
  49.  
  50. The Gnome Canvas is an engine for structured graphics that offers a
  51. rich imaging model, high-performance rendering, and a powerful,
  52. high level API.  It offers a choice of two rendering back-ends,
  53. one based on GDK for extremely fast display, and another based on
  54. Libart, a sophisticated, antialiased, alpha-compositing engine.
  55. This widget can be used for flexible display of graphics and for
  56. creating interactive user interface elements.
  57.  
  58. To create a new Gnome2::Canvas widget call C<< Gnome2::Canvas->new >> or
  59. C<< Gnome2::Canvas->new_aa >> for an anti-aliased mode canvas.
  60.  
  61. A Gnome2::Canvas contains one or more Gnome2::CanvasItem
  62. objects. Items consist of graphing elements like lines, ellipses,
  63. polygons, images, text, and curves.  These items are organized using
  64. Gnome2::CanvasGroup objects, which are themselves derived from
  65. Gnome2::CanvasItem.  Since a group is an item it can be contained within
  66. other groups, forming a tree of canvas items.  Certain operations, like
  67. translating and scaling, can be performed on all items in a group.
  68.  
  69. There is a special root group created by a Gnome2::Canvas.  This is the top
  70. level group under which all items in a canvas are contained.  The root group
  71. is available as C<< $canvas->root >>.
  72.  
  73. There are several different coordinate systems used by Gnome2::Canvas
  74. widgets.  The primary system is a logical, abstract coordinate space
  75. called world coordinates.  World coordinates are expressed as unbounded
  76. double floating point numbers.  When it comes to rendering to a screen
  77. the canvas pixel coordinate system (also referred to as just canvas
  78. coordinates) is used.  This system uses integers to specify screen
  79. pixel positions.  A user defined scaling factor and offset are used to
  80. convert between world coordinates and canvas coordinates.  Each item in
  81. a canvas has its own coordinate system called item coordinates.  This
  82. system is specified in world coordinates but they are relative to an
  83. item (0.0, 0.0 would be the top left corner of the item).  The final
  84. coordinate system of interest is window coordinates.  These are like
  85. canvas coordinates but are offsets from within a window a canvas is
  86. displayed in.  This last system is rarely used, but is useful when
  87. manually handling GDK events (such as drag and drop) which are 
  88. specified in window coordinates (the events processed by the canvas
  89. are already converted for you).
  90.  
  91. Along with different coordinate systems come methods to convert
  92. between them.  C<< $canvas->w2c >> converts world to canvas pixel
  93. coordinates and C<< canvas->c2w >> converts from canvas to
  94. world.  To get the affine transform matrix for converting
  95. from world coordinates to canvas coordinates call C<< $canvas->w2c_affine >>.
  96. C<< $canvas->window_to_world >> converts from window to world
  97. coordinates and C<< $canvas->world_to_window >> converts in the other
  98. direction.  There are no methods for converting between canvas and
  99. window coordinates, since this is just a matter of subtracting the
  100. canvas scrolling offset.  To convert to/from item coordinates use the
  101. methods defined for Gnome2::CanvasItem objects.
  102.  
  103. To set the canvas zoom factor (canvas pixels per world unit, the
  104. scaling factor) call C<< $canvas->set_pixels_per_unit >>; setting this
  105. to 1.0 will cause the two coordinate systems to correspond (e.g., [5, 6]
  106. in pixel units would be [5.0, 6.0] in world units).
  107.  
  108. Defining the scrollable area of a canvas widget is done by calling
  109. C<< $canvas->set_scroll_region >> and to get the current region
  110. C<< $canvas->get_scroll_region >> can be used.  If the window is
  111. larger than the canvas scrolling region it can optionally be centered
  112. in the window.  Use C<< $canvas->set_center_scroll_region >> to enable or
  113. disable this behavior.  To scroll to a particular canvas pixel coordinate
  114. use C<< $canvas->scroll_to >> (typically not used since scrollbars are
  115. usually set up to handle the scrolling), and to get the current canvas pixel
  116. scroll offset call C<< $canvas->get_scroll_offsets >>.
  117.  
  118. =cut
  119.  
  120.  
  121.  
  122. =head1 HIERARCHY
  123.  
  124.   Glib::Object
  125.   +----Glib::InitiallyUnowned
  126.        +----Gtk2::Object
  127.             +----Gtk2::Widget
  128.                  +----Gtk2::Container
  129.                       +----Gtk2::Layout
  130.                            +----Gnome2::Canvas
  131.  
  132. =head1 INTERFACES
  133.  
  134.   Glib::Object::_Unregistered::AtkImplementorIface
  135.   Gtk2::Buildable
  136.  
  137. =for object Gnome2::Canvas A structured graphics canvas
  138.  
  139. =cut
  140.  
  141.  
  142.  
  143.  
  144. =head1 METHODS
  145.  
  146. =head2 widget = Gnome2::Canvas-E<gt>B<new> 
  147.  
  148. =over
  149.  
  150. Create a new empty canvas in non-antialiased mode.
  151.  
  152. =back
  153.  
  154. =head2 widget = Gnome2::Canvas-E<gt>B<new_aa> 
  155.  
  156. =over
  157.  
  158. Create a new empty canvas in antialiased mode.
  159.  
  160. =back
  161.  
  162. =head2 boolean = $canvas->B<aa>
  163.  
  164. =over
  165.  
  166.  
  167. Returns true if I<$canvas> was created in anti-aliased mode.
  168.  
  169.  
  170. =back
  171.  
  172. =head2 ($bx1, $by1, $bx2, $by2) = Gnome2::Canvas->B<get_butt_points> ($x1, $y1, $x2, $y2, $width, $project)
  173.  
  174. =over
  175.  
  176. =over
  177.  
  178. =item * $x1 (double) 
  179.  
  180. =item * $y1 (double) 
  181.  
  182. =item * $x2 (double) 
  183.  
  184. =item * $y2 (double) 
  185.  
  186. =item * $width (double) 
  187.  
  188. =item * $project (integer) 
  189.  
  190. =back
  191.  
  192.  
  193.  
  194. =back
  195.  
  196. =head2 (wx, wy) = $canvas-E<gt>B<c2w> ($cx, $cy)
  197.  
  198. =over
  199.  
  200. =over
  201.  
  202. =item * $cx (integer) 
  203.  
  204. =item * $cy (integer) 
  205.  
  206. =back
  207.  
  208. =back
  209.  
  210. =head2 boolean = $canvas-E<gt>B<get_center_scroll_region> 
  211.  
  212. =over
  213.  
  214. =back
  215.  
  216. =head2 $canvas-E<gt>B<set_center_scroll_region> ($center_scroll_region)
  217.  
  218. =over
  219.  
  220. =over
  221.  
  222. =item * $center_scroll_region (boolean) 
  223.  
  224. =back
  225.  
  226. =back
  227.  
  228. =head2 list = $canvas-E<gt>B<get_color> ($spec)
  229.  
  230. =over
  231.  
  232. =over
  233.  
  234. =item * $spec (string) 
  235.  
  236. =back
  237.  
  238.  
  239. Returns an integer indicating the success of the color allocation and a
  240. GdkColor.
  241.  
  242.  
  243. =back
  244.  
  245. =head2 unsigned = $canvas-E<gt>B<get_color_pixel> ($rgba)
  246.  
  247. =over
  248.  
  249. =over
  250.  
  251. =item * $rgba (integer) 
  252.  
  253. =back
  254.  
  255. =back
  256.  
  257. =head2 rgbdither = $canvas-E<gt>B<get_dither> 
  258.  
  259. =over
  260.  
  261. =back
  262.  
  263. =head2 $canvas-E<gt>B<set_dither> ($dither)
  264.  
  265. =over
  266.  
  267. =over
  268.  
  269. =item * $dither (Gtk2::Gdk::RgbDither) 
  270.  
  271. =back
  272.  
  273. =back
  274.  
  275. =head2 item = $canvas-E<gt>B<get_item_at> ($x, $y)
  276.  
  277. =over
  278.  
  279. =over
  280.  
  281. =item * $x (double) 
  282.  
  283. =item * $y (double) 
  284.  
  285. =back
  286.  
  287. =back
  288.  
  289. =head2 ($mx1, $my1, $mx2, $my2) = Gnome2::Canvas->B<get_miter_points> ($x1, $y1, $x2, $y2, $x3, $y3, $width)
  290.  
  291. =over
  292.  
  293. =over
  294.  
  295. =item * $x1 (double) 
  296.  
  297. =item * $y1 (double) 
  298.  
  299. =item * $x2 (double) 
  300.  
  301. =item * $y2 (double) 
  302.  
  303. =item * $x3 (double) 
  304.  
  305. =item * $y3 (double) 
  306.  
  307. =item * $width (double) 
  308.  
  309. =back
  310.  
  311.  
  312.  
  313. =back
  314.  
  315. =head2 double = $canvas->B<get_pixels_per_unit>
  316.  
  317. =over
  318.  
  319. Fetch I<$canvas>' scale factor.
  320.  
  321. =back
  322.  
  323. =head2 $canvas-E<gt>B<set_pixels_per_unit> ($n)
  324.  
  325. =over
  326.  
  327. =over
  328.  
  329. =item * $n (double) 
  330.  
  331. =back
  332.  
  333.  
  334. Set the zooming factor of I<$canvas> by specifying the number of screen
  335. pixels that correspond to one canvas unit.
  336.  
  337.  
  338. =back
  339.  
  340. =head2 double = Gnome2::Canvas-E<gt>B<polygon_to_point> ($poly_ref, $x, $y)
  341.  
  342. =over
  343.  
  344. =over
  345.  
  346. =item * $poly_ref (arrayref) coordinate pairs that make up the polygon
  347.  
  348. =item * $x (double) 
  349.  
  350. =item * $y (double) 
  351.  
  352. =back
  353.  
  354. Return the distance from the point I<$x>,I<$y> to the polygon described by
  355. the vertices in I<$poly_ref>, or zero if the point is inside the polygon.
  356.  
  357. =back
  358.  
  359. =head2 $canvas-E<gt>B<request_redraw> ($x1, $y1, $x2, $y2)
  360.  
  361. =over
  362.  
  363. =over
  364.  
  365. =item * $x1 (integer) 
  366.  
  367. =item * $y1 (integer) 
  368.  
  369. =item * $x2 (integer) 
  370.  
  371. =item * $y2 (integer) 
  372.  
  373. =back
  374.  
  375. =back
  376.  
  377. =head2 group = $canvas-E<gt>B<root> 
  378.  
  379. =over
  380.  
  381. =back
  382.  
  383. =head2 (cx, cy) = $canvas-E<gt>B<get_scroll_offsets> 
  384.  
  385. =over
  386.  
  387. =back
  388.  
  389. =head2 (x1, y1, x2, y2) = $canvas-E<gt>B<get_scroll_region> 
  390.  
  391. =over
  392.  
  393. =back
  394.  
  395. =head2 $canvas-E<gt>B<set_scroll_region> ($x1, $y1, $x2, $y2)
  396.  
  397. =over
  398.  
  399. =over
  400.  
  401. =item * $x1 (double) 
  402.  
  403. =item * $y1 (double) 
  404.  
  405. =item * $x2 (double) 
  406.  
  407. =item * $y2 (double) 
  408.  
  409. =back
  410.  
  411. =back
  412.  
  413. =head2 $canvas-E<gt>B<scroll_to> ($cx, $cy)
  414.  
  415. =over
  416.  
  417. =over
  418.  
  419. =item * $cx (integer) 
  420.  
  421. =item * $cy (integer) 
  422.  
  423. =back
  424.  
  425. =back
  426.  
  427. =head2 $canvas-E<gt>B<set_stipple_origin> ($gc)
  428.  
  429. =over
  430.  
  431. =over
  432.  
  433. =item * $gc (Gtk2::Gdk::GC) 
  434.  
  435. =back
  436.  
  437. =back
  438.  
  439. =head2 $canvas-E<gt>B<update_now> 
  440.  
  441. =over
  442.  
  443. =back
  444.  
  445. =head2 (cx, cy) = $canvas-E<gt>B<w2c> ($wx, $wy)
  446.  
  447. =over
  448.  
  449. =over
  450.  
  451. =item * $wx (double) 
  452.  
  453. =item * $wy (double) 
  454.  
  455. =back
  456.  
  457. =back
  458.  
  459. =head2 $affine = $canvas->B<w2c_affine>
  460.  
  461. =over
  462.  
  463. =over
  464.  
  465. =back
  466.  
  467. Fetch the affine transform that converts from world coordinates to canvas
  468. pixel coordinates.
  469.  
  470. Note: This method was completely broken for all
  471. $Gnome2::Canvas::VERSION < 1.002.
  472.  
  473. =back
  474.  
  475. =head2 (cx, cy) = $canvas-E<gt>B<w2c_d> ($wx, $wy)
  476.  
  477. =over
  478.  
  479. =over
  480.  
  481. =item * $wx (double) 
  482.  
  483. =item * $wy (double) 
  484.  
  485. =back
  486.  
  487. =back
  488.  
  489. =head2 (worldx, worldy) = $canvas-E<gt>B<window_to_world> ($winx, $winy)
  490.  
  491. =over
  492.  
  493. =over
  494.  
  495. =item * $winx (double) 
  496.  
  497. =item * $winy (double) 
  498.  
  499. =back
  500.  
  501. =back
  502.  
  503. =head2 (winx, winy) = $canvas-E<gt>B<world_to_window> ($worldx, $worldy)
  504.  
  505. =over
  506.  
  507. =over
  508.  
  509. =item * $worldx (double) 
  510.  
  511. =item * $worldy (double) 
  512.  
  513. =back
  514.  
  515. =back
  516.  
  517.  
  518. =head1 PROPERTIES
  519.  
  520. =over
  521.  
  522. =item 'aa' (boolean : readable / writable / construct-only)
  523.  
  524. The antialiasing mode of the canvas.
  525.  
  526. =item 'focused-item' (Gnome2::Canvas::Item : readable / writable)
  527.  
  528. =back
  529.  
  530.  
  531. =head1 SIGNALS
  532.  
  533. =over
  534.  
  535. =item B<draw-background> (Gnome2::Canvas, Gtk2::Gdk::Drawable, integer, integer, integer, integer)
  536.  
  537. =item B<render-background> (Gnome2::Canvas, gpointer)
  538.  
  539. =back
  540.  
  541.  
  542. =head1 ENUMS AND FLAGS
  543.  
  544. =head2 enum Gtk2::Gdk::RgbDither
  545.  
  546. =over
  547.  
  548. =item * 'none' / 'GDK_RGB_DITHER_NONE'
  549.  
  550. =item * 'normal' / 'GDK_RGB_DITHER_NORMAL'
  551.  
  552. =item * 'max' / 'GDK_RGB_DITHER_MAX'
  553.  
  554. =back
  555.  
  556.  
  557. =for position SEE_ALSO
  558.  
  559. =head1 SEE ALSO
  560.  
  561. Gnome2::Canvas::index(3pm) lists the generated Perl API reference PODs.
  562.  
  563. Frederico Mena Quintero's whitepaper on the GNOME Canvas:
  564. http://developer.gnome.org/doc/whitepapers/canvas/canvas.html
  565.  
  566. The real GnomeCanvas is implemented in a C library; the Gnome2::Canvas module
  567. allows a Perl developer to use the canvas like a normal gtk2-perl object.
  568. Like the Gtk2 module on which it depends, Gnome2::Canvas follows the C API of
  569. libgnomecanvas-2.0 as closely as possible while still being perlish.
  570. Thus, the C API reference remains the canonical documentation; the Perl
  571. reference documentation lists call signatures and argument types, and is
  572. meant to be used in conjunction with the C API reference.
  573.  
  574. GNOME Canvas Library Reference Manual
  575. http://developer.gnome.org/doc/API/2.0/libgnomecanvas/index.html
  576.  
  577. perl(1), Glib(3pm), Gtk2(3pm).
  578.  
  579. To discuss gtk2-perl, ask questions and flame/praise the authors,
  580. join gtk-perl-list@gnome.org at lists.gnome.org.
  581.  
  582. =cut
  583.  
  584.  
  585.  
  586. =for position COPYRIGHT
  587.  
  588. =head1 AUTHOR
  589.  
  590. muppet <scott at asofyet dot org>, with patches from
  591. Torsten Schoenfeld <kaffetisch at web dot de>.
  592.  
  593. The DESCRIPTION section of this page is adapted from the documentation of
  594. libgnomecanvas.
  595.  
  596. =head1 COPYRIGHT AND LICENSE
  597.  
  598. Copyright 2003-2004 by the gtk2-perl team.
  599.  
  600. This library is free software; you can redistribute it and/or
  601. modify it under the terms of the GNU Library General Public
  602. License as published by the Free Software Foundation; either
  603. version 2 of the License, or (at your option) any later version.
  604.  
  605. This library is distributed in the hope that it will be useful,
  606. but WITHOUT ANY WARRANTY; without even the implied warranty of
  607. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  608. Library General Public License for more details.
  609.  
  610. You should have received a copy of the GNU Library General Public
  611. License along with this library; if not, write to the 
  612. Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
  613. Boston, MA  02111-1307  USA.
  614.  
  615. =cut
  616.  
  617.  
  618.  
  619.  
  620. =cut
  621.  
  622.